using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Legend.Guarding;

namespace Legend.Core.Tests.Guarding
{
    [TestFixture]
    public class DefaultRandomNumberGeneratorTests
    {
        private DefaultRandomNumberGenerator generator;

        [SetUp]
        public void SetUp()
        {
            this.generator = new DefaultRandomNumberGenerator();
        }

        [TestCase(0, 0)]
        [TestCase(0, 1)]
        [TestCase(256, 1024)]
        [TestCase(0, int.MaxValue - 1)]
        [TestCase(int.MaxValue - 1, int.MaxValue - 1)]
        [TestCase(int.MinValue, int.MaxValue - 1)]
        [TestCase(int.MinValue, 0)]
        [TestCase(int.MinValue, int.MinValue)]
        public void GenerateRandomInteger_should_not_fail_for_valid_value_combinations(int minValue, int maxValue)
        {
            Assert.DoesNotThrow(() => this.generator.GetRandomInteger(minValue, maxValue));
        }

        [TestCase(0, -1)]
        [TestCase(10, 3)]
        [TestCase(int.MaxValue - 1, int.MinValue)]
        public void GenerateRandomInteger_should_fail_for_invalid_value_combinations(int minValue, int maxValue)
        {
            // Arrange

            // Act

            // Assert
            Assert.That(() => this.generator.GetRandomInteger(minValue, maxValue), Throws.TypeOf<ArgumentOutOfRangeException>());
        }

        [Test]
        public void GenerateRandomInteger_should_produce_exact_value_when_called_with_same_min_and_maxvalue()
        {
            // Arrange

            // Act
            var result = this.generator.GetRandomInteger(10, 10);

            // Assert
            Assert.That(result, Is.EqualTo(10));
        }
    }
}
